package com.bulong.demo.slice;

import com.bulong.rudeness.RudenessScreenHelper;
import com.bulong.demo.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.DirectionalLayout;
import ohos.agp.components.Image;
import ohos.agp.components.Text;
import ohos.agp.utils.Color;

/**
 * Created by Caodongyao on 2017/7/28.
 */

public class RudeAbilitySlice extends AbilitySlice {

    private static final int THIRTY = 30;
    private static final int SEVENTEEN = 17;
    private static final int FIFTEEN = 15;
    private static final int HUNDRED = 135;
    private static final int EIGHTEEN = 18;
    private static final int SIXTY = 60;
    private static final int FIVE = 5;
    private static final int TEN = 10;
    private static final int FOURTY_FIVE = 45;


    /**
     * 初始化
     **/
    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_rude);

        initBottom();
        initFour();
    }

    /**
     * 条目
     **/
    public void initFour() {
        DirectionalLayout tab = (DirectionalLayout) findComponentById(ResourceTable.Id_four);
        Text textLeft = (Text) tab.findComponentById(ResourceTable.Id_four_left);
        textLeft.setTextSize((int) RudenessScreenHelper.vp2px(THIRTY, getContext()));
        Text textCenter = (Text) tab.findComponentById(ResourceTable.Id_four_center);
        textCenter.setWidth((int) RudenessScreenHelper.vp2px(0, getContext()));
        textCenter.setMarginLeft((int) RudenessScreenHelper.vp2px(FIFTEEN, getContext()));
        textCenter.setTextSize((int) RudenessScreenHelper.vp2px(SEVENTEEN, getContext()));
        Text textRight = (Text) tab.findComponentById(ResourceTable.Id_four_right);
        textRight.setTextSize((int) RudenessScreenHelper.vp2px(THIRTY, getContext()));
    }

    /**
     * 条目
     **/
    public void initBottom() {

        //获取主页面底部容器ID
        DirectionalLayout tab = (DirectionalLayout) findComponentById(ResourceTable.Id_rude_tab);
        Text buttonLogin = (Text) tab.findComponentById(ResourceTable.Id_log_in);
        buttonLogin.setTextSize((int) RudenessScreenHelper.vp2px(SEVENTEEN, getContext()));
        buttonLogin.setHeight((int) RudenessScreenHelper.vp2px(FOURTY_FIVE, getContext()));

        // 条目四
        DirectionalLayout tabFour = (DirectionalLayout) findComponentById(ResourceTable.Id_rude_tabeFour);
        Text entryFour = (Text) tabFour.findComponentById(ResourceTable.Id_entryFour);
        entryFour.setTextSize((int) RudenessScreenHelper.vp2px(SEVENTEEN, getContext()));
        entryFour.setMarginLeft((int) RudenessScreenHelper.vp2px(FIFTEEN, getContext()));
        entryFour.setTextColor(Color.BLACK);
        // 条目三
        DirectionalLayout tabThree = (DirectionalLayout) findComponentById(ResourceTable.Id_rude_tabeThree);
        Text entryThree = (Text) tabThree.findComponentById(ResourceTable.Id_entryThree);
        entryThree.setTextSize((int) RudenessScreenHelper.vp2px(SEVENTEEN, getContext()));
        entryThree.setMarginLeft((int) RudenessScreenHelper.vp2px(FIFTEEN, getContext()));
        entryThree.setTextColor(Color.BLACK);

        // 条目一 和title
        DirectionalLayout title = (DirectionalLayout) findComponentById(ResourceTable.Id_title);
        title.setHeight((int) RudenessScreenHelper.vp2px(HUNDRED, getContext()));
        Image image = (Image) findComponentById(ResourceTable.Id_normal_image);
        image.setMarginLeft((int) RudenessScreenHelper.vp2px(THIRTY, getContext()));
        Text normalText = (Text) tab.findComponentById(ResourceTable.Id_normal_text);
        normalText.setTextSize((int) RudenessScreenHelper.vp2px(EIGHTEEN, getContext()));
        normalText.setMarginLeft((int) RudenessScreenHelper.vp2px(SIXTY, getContext()));
        Text titleOneText = (Text) findComponentById(ResourceTable.Id_title_one_text);
        titleOneText.setMarginTop((int) RudenessScreenHelper.vp2px(FIVE, getContext()));
        Text titleTwoText = (Text) findComponentById(ResourceTable.Id_title_two_text);
        titleTwoText.setMarginTop((int) RudenessScreenHelper.vp2px(FIVE, getContext()));
        Text titleThreeText = (Text) findComponentById(ResourceTable.Id_title_three_text);
        titleThreeText.setMarginTop((int) RudenessScreenHelper.vp2px(FIVE, getContext()));
        Text titleUnderOne = (Text) findComponentById(ResourceTable.Id_title_underline_one);
        titleUnderOne.setHeight((int) RudenessScreenHelper.vp2px(1, getContext()));
        Text titleUnderTow = (Text) findComponentById(ResourceTable.Id_title_underline_two);
        titleUnderTow.setHeight((int) RudenessScreenHelper.vp2px(1, getContext()));
        titleUnderTow.setMarginTop((int) RudenessScreenHelper.vp2px(TEN, getContext()));
        DirectionalLayout contentOne = (DirectionalLayout) findComponentById(ResourceTable.Id_content_one);
        contentOne.setHeight((int) RudenessScreenHelper.vp2px(FOURTY_FIVE, getContext()));
        contentOne.setPaddingLeft((int) RudenessScreenHelper.vp2px(FIFTEEN, getContext()));
        contentOne.setPaddingRight((int) RudenessScreenHelper.vp2px(FIFTEEN, getContext()));
        Text contentOneText = (Text) findComponentById(ResourceTable.Id_content_one_text);
        contentOneText.setMarginLeft((int) RudenessScreenHelper.vp2px(FIFTEEN, getContext()));
    }
}